﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>SSE Test</title>
</head>
<body>
    <div id="container">
    </div>
    <script>
        if (typeof (EventSource) !== "undefined") {
            var container = document.getElementById("container");
            var es = new EventSource("/home/sse");
            es.onopen = function (event) {
                container.innerHTML += "open<br/>";
            }
            es.onmessage = function (event) {
                container.innerHTML += event.data + "<br/>";
            };
            es.onerror = function (event) {
                console.log(event);
                container.innerHTML += "error<br/>";
                es.close();
            }
        }
        else {
            console.log("一边儿玩儿去");
        }
    </script>
</body>
</html>